<template>
  <div id="warrper">
    <div class="wrap">
      <div class="wrap-in">
        <div class="rw">
          <div class="t-l inline push green unclickable" id="3"></div>
          <div class="t-r inline push red but unclickable" id="2"></div>
        </div>
        <div class="rw">
          <div class="b-l inline push yellow unclickable" id="1"></div>
          <div class="b-r inline push blue but unclickable" id="0"></div>
        </div>
      </div>
      <div class="center">
        <h1 class="brand">Config</h1>
        <div class="rw">
          <div class="display inline">
            <h1 class="count led-off"><input type="text" v-model="count" @blur="blurCount" /></h1>
            <h3 class="label">Min</h3>
          </div>
          <div class="btn-box inline" @click="onStart">
            <div class="round-btn full-red but clickable" id="start"></div>
            <h3 class="label">START</h3>
          </div>
        </div>
        <div class="rw bot">
          <h3 class="label inline">OFF</h3>
          <div class="sw-slot inline" @click="checked = !checked">
            <div class="switch" :class="{ 'sw-on': checked }"></div>
          </div>
          <h3 class="label inline">ON</h3>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "configcount-page",
  data() {
    return {
      count: 3,
      checked: false,
    };
  },
  created() {
      this.count = localStorage.getItem("count") || 3;
      this.checked = localStorage.getItem("checked") || false;
      console.log(this.count)
  },
  computed: {},
  methods: {
    blurCount(){
      this.count = Math.abs(Object.is(+this.count,NaN)?3:this.count);
    },
    onStart() {
      console.log(this.$router);
      if (this.checked) {
        localStorage.setItem("count", this.count);
        localStorage.setItem("checked", this.checked);
      } else {
        localStorage.setItem("checked", "");
        localStorage.setItem("count", 3);
      }
      this.$router.push({
        name: "downcount",
        query: {
          count: this.count,
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
// @import url("https://fonts.googleapis.com/css?family=Alfa+Slab+One|VT323|Oswald");
// @import url("../assets/AlfaSlabOne-Regular.ttf");
@font-face {
    font-family:"VT323";
    src: url("../assets/VT323-Regular.ttf");
}
@font-face {
    font-family:"Alfa Slab One";
    src: url("../assets/AlfaSlabOne-Regular.ttf");
}
@font-face {
    font-family:"Oswald";
    src: url("../assets/Oswald-Regular.ttf");
}
#warrper {
  width: 100%;
  height: 100vh;
  background: url("../assets/wood.jpg") no-repeat;
  background: 100% auto;
}
.inline {
  display: inline-block;
}

.push {
  position: relative;
  width: 200px;
  height: 200px;
  background-color: grey;
  border: 12px solid #333;
}

.rw {
  margin-bottom: -4px;
}

.b-r {
  border-bottom-right-radius: 100%;
}

.b-l {
  border-bottom-left-radius: 100%;
}

.t-l {
  border-top-left-radius: 100%;
}

.t-r {
  border-top-right-radius: 100%;
}

.wrap {
  width: 472px;
  height: 472px;
  border-radius: 100%;
  position: relative;
  text-align: center;
  margin: auto;
  background-color: #333;
  top: 10vh;
  box-shadow: 0px 0px 12px #222;
}

.wrap-in {
  position: relative;
  top: 12px;
}
.center {
  width: 220px;
  height: 220px;
  position: absolute;
  border-radius: 100%;
  top: 50%;
  left: 50%;
  margin: -122px 0 0 -122px;
  background-color: #ece7ee;
  border: 12px solid #333;
}

.brand {
  font-family: "Alfa Slab One", cursive;
  color: #222;
  font-size: 3.2em;
  margin-top: 35px;
}

.brand .small {
  font-size: 0.3em;
  position: relative;
  top: -20px;
}

.count {
  font-family: "VT323", monospace;
  color: #dc0d29;
  padding: 0px;
  font-size: 2em;
  width: 50px;
  background-color: #32050c;
  position: relative;
  border: 4px solid #222;
  border-radius: 10px;
  margin: auto;
  input {
    font-family: "VT323", monospace;
    color: #dc0d29;
    width: 100%;
    padding: 0;
    text-align: center;
    font-size: 1em;
    background-color: transparent;
    border: 0;
    outline: none;
  }
}

.round-btn {
  width: 20px;
  height: 20px;
  position: relative;
  background-color: yellow;
  border-radius: 100%;
  border: 4px solid #444;
  box-shadow: 0px 2px 3px #222;
  margin: auto;
  top: -5px;
}

.round-btn:active {
  box-shadow: 0 1px 1px #292929;
  top: -4px;
}

.clickable {
  pointer-events: auto;
  cursor: pointer;
}

.unclickable {
  pointer-events: none;
}

.led {
  width: 6px;
  height: 6px;
  background-color: #32050c;
  border-radius: 100%;
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
  border: 2px solid #222;
  top: -18px;
}

.led-on {
  background-color: #dc0d29;
}

.led-off {
  color: #430710;
}

.label {
  color: #222;
  font-family: "Oswald", Arial, sans;
  font-size: 0.7em;
  margin-top: 5px;
  text-align: center;
}

.display {
  width: 60px;
  position: relative;
  text-align: center;
}

.btn-box {
  width: 50px;
  position: relative;
}

.sw-slot {
  height: 20px;
  width: 40px;
  background-color: #222;
  position: relative;
  top: 5px;
  border-radius: 2px;
  cursor: pointer;
}

.switch {
  height: 16px;
  width: 16px;
  border-radius: 4px;
  background-color: #3193de;
  position: relative;
  border: 2px solid #333;
}

.sw-on {
  left: 20px;
}
.rw.bot {
  margin-top: 10px;
}
.full-red {
  background-color: #fc0102;
}
.red {
  background-color: #9f0f17;
}

.green {
  background-color: #00a74a;
}

.yellow {
  background-color: #cca707;
}

.blue {
  background-color: #094a8f;
}

.yellow.light {
  background-color: #fed93f;
}

.blue.light {
  background-color: #1c8cff;
}

.red.light {
  background-color: #ff4c4c;
}

.green.light {
  background-color: #13ff7c;
}

/* Scaling for Mobile */
@media screen and (max-width: 500px) {
  .wrap {
    top: 40px;

    -moz-transform: scale(0.6);
    -ms-transform: scale(0.6);
    -o-transform: scale(0.6);
    -webkit-transform: scale(0.6);
    transform: scale(0.6);

    -o-transform-origin: 0 0;
    -ms-transform-origin: 0 0;
    -webkit-transform-origin: 0 0;
    -moz-transform-origin: 0 0;
    transform-origin: 0 0;

    left: 50%;
    margin-left: -142px;
  }
}
</style>
